//
//  HMNavigationController.swift
//  weibo
//
//  Created by LCH on 16/3/4.
//  Copyright © 2016年 lch. All rights reserved.
//

import UIKit

class HMNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    // 重写push方法,判断child
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
//        print(childViewControllers.count)
        
        if childViewControllers.count > 0 {
            
//            print(childViewControllers.count)
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: "返回", target:self, action: "back")
            viewController.hidesBottomBarWhenPushed = true
            }
        super.pushViewController(viewController, animated: true)
        
    }
    
    func back() {
    
      popViewControllerAnimated(true)
    }

}
